package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.stat.OrderCumStaDao;
import com.tbit.main.pojo.OrderCumSta;
import com.tbit.main.service.OrderCumStaService;
import com.tbit.main.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LMY
 * @create 2021-01-19 18:53
 * 订单总统计
 */
@Service("orderCumStaService")
public class OrderCumStaServiceImpl implements OrderCumStaService {

    @Autowired
    private OrderCumStaDao orderCumStaDao;

    @Override
    public OrderCumSta getByAccountIdDateDay(List<Integer> accountId, Integer type) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, StringUtil.getListString(accountId));
        map.put("type", type);
        return orderCumStaDao.getByAccountIdDateDay(map);
    }

    @Override
    public OrderCumSta getByAccountIdDateWeek(Integer accountId, String startDate, String endDate) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        return orderCumStaDao.getByAccountIdDateWeek(map);
    }

    @Override
    public OrderCumSta getByAccountIdDateMonth(Integer accountId, String startDate, String endDate) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        return orderCumStaDao.getByAccountIdDateMonth(map);
    }

    @Override
    public List<OrderCumSta> getByAccountIds(List<Integer> accountId, Integer type) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, StringUtil.getListString(accountId));
        map.put("type", type);
        return orderCumStaDao.getByAccountIds(map);
    }

    @Override
    public List<OrderCumSta> getByAccountId(Integer accountId) {
        return orderCumStaDao.getByAccountId(accountId);
    }
}
